package com.chis.jmdatatimer.comm;

import com.chis.jm.pojo.TdChiltransHand;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import redis.clients.jedis.ShardedJedis;

import java.util.List;

/**
 * @Description 根据儿童编码查询人工迁出表
 * @Company zwx
 * @author CZJ
 * @version 2016/7/25
 */
public class RedisFindTransHandTx implements TransactionJedis {
	/**日志*/
	private static Logger log = LogManager.getLogger(RedisFindTransHandTx.class);
	/** 儿童编码 */
	private String childCode;
	/** 人工迁出表集合 */
	private List<TdChiltransHand> list;

	public RedisFindTransHandTx(String childCode) {
		this.childCode = childCode;
	}

	@Override
	public void run(ShardedJedis jedis) throws Exception {

		try {
			jedis.select(10);
			byte[] bytes = jedis.get(childCode.getBytes());
			if (null != bytes && bytes.length > 0) {
				list = (List<TdChiltransHand>) JedisSerializeUtil.unserialize(bytes);
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw new Exception(e.getMessage());
		}

	}

	public List<TdChiltransHand> getList() {
		return list;
	}
}
